package com.wolves.career.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author mxs
 */
@Configuration
@EnableSwagger2 //必须要添加这个注解才能开启接口文档
public class SwaggerConfig {
    /**
     * 文档测试的配置
     *
     * @return
     */
    @Bean
    public Docket webApiConfig() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("职业测评接口文档")
                .apiInfo(webApiInfo())
                .select()
                .paths(Predicates.not(PathSelectors.regex("/admin/.*")))
                .paths(Predicates.not(PathSelectors.regex("/error.*")))
                .build();

    }

    /**
     * 文档信息描述的配置
     *
     * @return
     */
    private ApiInfo webApiInfo() {
        return new ApiInfoBuilder()
                .title("职业规划系统API文档")
                .description("职业规划系统接口定义")
                .version("1.0")
                .contact(new Contact("java", "http://career.com", "2426266434@qq.com"))
                .build();
    }
}
